/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package EL;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

/**
 *
 * @author Tian
 */
@Entity
@Table(name = "FoodType")
@NamedQueries(
{
    @NamedQuery(name = "FoodTypes.findAll", query = "SELECT f FROM FoodTypes f")
})
public class FoodTypes implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue (strategy=GenerationType.AUTO)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "category")
    private String category;
    @OneToMany(cascade = {CascadeType.MERGE,CascadeType.REFRESH,CascadeType.REMOVE}, mappedBy = "foodTypes")
    @LazyCollection(LazyCollectionOption.FALSE)
    private List<Foods> foodsList;

    public FoodTypes()
    {
    }

    public FoodTypes(String category)
    {
        this.category = category;
    }

    

    public Integer getId()
    {
        return id;
    }

    public void setId(Integer id)
    {
        this.id = id;
    }

    public String getCategory()
    {
        return category;
    }

    public void setCategory(String category)
    {
        this.category = category;
    }



    public List<Foods> getFoodsList()
    {
        return foodsList;
    }

    public void setFoodsList(List<Foods> foodsList)
    {
        this.foodsList = foodsList;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FoodTypes))
        {
            return false;
        }
        FoodTypes other = (FoodTypes) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "EL.FoodTypes[id=" + id + "]";
    }

}
